package test

import (
	"github.com/iris-contrib/middleware/csrf"
	"github.com/kataras/iris/v12"
)

var Test test

type test struct{}

func (r *test) CsrfShow(ctx iris.Context) {
	csrfToken := csrf.Token(ctx)
	ctx.ViewData("csrfToken", csrfToken)
	err := ctx.View("csrf.html")
	if err != nil {
		ctx.Application().Logger().Errorf("Failed to render view: %v", err)
		ctx.StatusCode(iris.StatusInternalServerError)
		_, _ = ctx.WriteString("Internal Server Error")
		return
	}
}
func (r *test) CsrfStore(ctx iris.Context) {
	_, _ = ctx.WriteString("Form submitted successfully!")
}
func (r *test) Error(ctx iris.Context) {
	ctx.StatusCode(iris.StatusInternalServerError)
	_, _ = ctx.WriteString("Something went wrong!")
}
